<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>海岛能源调度平台 - 安全登录</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary: #0066cc;
            --primary-light: #4d94ff;
            --primary-dark: #004d99;
            --secondary: #00b894;
            --dark: #2d3436;
            --light: #f8f9fa;
            --gray: #6c757d;
            --danger: #e74c3c;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s ease;
        }

        body {
            font-family: 'Poppins', sans-serif;
            background: linear-gradient(135deg, #0c2461, #1e3799, #4a69bd);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .login-container {
            display: flex;
            width: 900px;
            height: 550px;
            background: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            overflow: hidden;
            box-shadow: var(--shadow);
            position: relative;
        }

        .banner {
            flex: 1;
            background: linear-gradient(to bottom right, var(--primary), var(--secondary));
            color: white;
            padding: 50px 40px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }

        .banner::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none"><polygon points="0,100 100,0 100,100" fill="rgba(255,255,255,0.05)"/></svg>');
            background-size: cover;
        }

        .banner h1 {
            font-size: 32px;
            margin-bottom: 15px;
            font-weight: 700;
            z-index: 1;
        }

        .banner p {
            font-size: 16px;
            line-height: 1.8;
            margin-bottom: 25px;
            z-index: 1;
            font-weight: 300;
        }

        .features {
            margin-top: 30px;
            z-index: 1;
        }

        .feature {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .feature i {
            font-size: 20px;
            margin-right: 15px;
            color: rgba(255, 255, 255, 0.9);
        }

        .feature p {
            margin: 0;
            font-size: 15px;
        }

        .form-section {
            flex: 1;
            padding: 50px 40px;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .logo {
            display: flex;
            align-items: center;
            margin-bottom: 30px;
        }

        .logo-icon {
            width: 50px;
            height: 50px;
            background: var(--primary);
            color: white;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            margin-right: 15px;
            box-shadow: 0 5px 15px rgba(0, 102, 204, 0.3);
        }

        .logo-text {
            font-size: 24px;
            font-weight: 700;
            color: var(--dark);
        }

        .logo-text span {
            color: var(--primary);
        }

        .form-container {
            width: 100%;
        }

        .form-title {
            font-size: 26px;
            font-weight: 600;
            margin-bottom: 30px;
            color: var(--dark);
            position: relative;
        }

        .form-title::after {
            content: "";
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 50px;
            height: 4px;
            background: var(--primary);
            border-radius: 2px;
        }

        .input-group {
            margin-bottom: 25px;
            position: relative;
        }

        .input-group label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--dark);
            font-size: 14px;
        }

        .input-icon {
            position: absolute;
            left: 15px;
            top: 40px;
            color: var(--gray);
            font-size: 18px;
        }

        .input-field {
            width: 100%;
            padding: 15px 15px 15px 50px;
            border: 2px solid #e0e0e0;
            border-radius: 12px;
            font-size: 16px;
            transition: var(--transition);
            background: #f8f9fa;
        }

        .input-field:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
            outline: none;
            background: white;
        }

        .password-toggle {
            position: absolute;
            right: 15px;
            top: 40px;
            color: var(--gray);
            cursor: pointer;
            font-size: 18px;
        }

        .btn {
            width: 100%;
            padding: 15px;
            border: none;
            border-radius: 12px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            text-transform: uppercase;
            letter-spacing: 1px;
            margin-top: 10px;
        }

        .btn-login {
            background: var(--primary);
            color: white;
            box-shadow: 0 5px 15px rgba(0, 102, 204, 0.4);
        }

        .btn-login:hover {
            background: var(--primary-dark);
            transform: translateY(-2px);
            box-shadow: 0 7px 20px rgba(0, 102, 204, 0.5);
        }

        .btn-register {
            background: white;
            color: var(--primary);
            border: 2px solid var(--primary);
            margin-top: 15px;
        }

        .btn-register:hover {
            background: #f0f7ff;
        }

        .links {
            display: flex;
            justify-content: space-between;
            margin-top: 20px;
            font-size: 14px;
        }

        .link {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
        }

        .link i {
            margin-right: 5px;
        }

        .link:hover {
            color: var(--primary-dark);
            text-decoration: underline;
        }

        .form-switch {
            text-align: center;
            margin-top: 25px;
            font-size: 14px;
            color: var(--gray);
        }

        .error-message {
            color: var(--danger);
            font-size: 13px;
            margin-top: 5px;
            display: none;
        }

        .powered-by {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: rgba(255, 255, 255, 0.7);
            font-size: 12px;
            text-align: right;
        }

        @media (max-width: 768px) {
            .login-container {
                flex-direction: column;
                width: 100%;
                height: auto;
            }

            .banner {
                padding: 30px 20px;
            }

            .form-section {
                padding: 30px 20px;
            }

            .powered-by {
                position: static;
                margin-top: 20px;
                text-align: center;
                color: var(--gray);
            }
        }
    </style>
</head>
<body>
<div class="login-container">
    <div class="banner">
        <h1>海岛综合能源系统运行调度平台</h1>
        <p>全球能源低碳化与智能化转型背景下，实现可再生能源高效消纳与多能协同优化</p>

        <div class="features">
            <div class="feature">
                <i class="fas fa-bolt"></i>
                <p>基于能源预测与优化调度的智能决策平台</p>
            </div>
            <div class="feature">
                <i class="fas fa-chart-line"></i>
                <p>融合STL分解与LSTM深度学习的能源预测模块</p>
            </div>
            <div class="feature">
                <i class="fas fa-cogs"></i>
                <p>DIC-MOEA/D算法实现多目标优化调度</p>
            </div>
        </div>

        <div class="powered-by">
            青岛科技大学数据科学技术学院<br>
            毕业设计项目
        </div>
    </div>

    <div class="form-section">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-bolt"></i>
            </div>
            <div class="logo-text">海岛<span>能源</span></div>
        </div>

        <div class="form-container" id="login-form-container">
            <h2 class="form-title">欢迎登录</h2>

            <div class="input-group">
                <label for="username">用户名</label>
                <div class="input-icon">
                    <i class="fas fa-user"></i>
                </div>
                <input type="text" id="username" class="input-field" placeholder="请输入用户名" required>
                <div class="error-message" id="username-error"></div>
            </div>

            <div class="input-group">
                <label for="password">密码</label>
                <div class="input-icon">
                    <i class="fas fa-lock"></i>
                </div>
                <input type="password" id="password" class="input-field" placeholder="请输入密码" required>
                <span class="password-toggle" id="password-toggle">
                        <i class="fas fa-eye"></i>
                    </span>
                <div class="error-message" id="password-error"></div>
            </div>

            <button type="button" class="btn btn-login" id="login-btn">登 录</button>

            <div class="links">
                <a href="#" class="link" id="forgot-link">
                    <i class="fas fa-key"></i> 忘记密码?
                </a>
                <a href="#" class="link" id="register-link">
                    <i class="fas fa-user-plus"></i> 创建新账户
                </a>
            </div>
        </div>

        <div class="form-container" id="register-form-container" style="display:none;">
            <h2 class="form-title">创建账户</h2>

            <div class="input-group">
                <label for="reg-username">用户名</label>
                <div class="input-icon">
                    <i class="fas fa-user"></i>
                </div>
                <input type="text" id="reg-username" class="input-field" placeholder="设置用户名" required>
                <div class="error-message" id="reg-username-error"></div>
            </div>

            <div class="input-group">
                <label for="reg-password">密码</label>
                <div class="input-icon">
                    <i class="fas fa-lock"></i>
                </div>
                <input type="password" id="reg-password" class="input-field" placeholder="设置密码 (至少8位)" required>
                <span class="password-toggle" id="reg-password-toggle">
                        <i class="fas fa-eye"></i>
                    </span>
                <div class="error-message" id="reg-password-error"></div>
            </div>

            <div class="input-group">
                <label for="confirm-password">确认密码</label>
                <div class="input-icon">
                    <i class="fas fa-lock"></i>
                </div>
                <input type="password" id="confirm-password" class="input-field" placeholder="再次输入密码" required>
                <div class="error-message" id="confirm-password-error"></div>
            </div>

            <button type="button" class="btn btn-login" id="register-btn">注 册</button>

            <div class="form-switch">
                已有账户? <a href="#" class="link" id="login-link"><i class="fas fa-sign-in-alt"></i> 返回登录</a>
            </div>
        </div>
    </div>
</div>

<script>
    // 页面元素引用
    const loginFormContainer = document.getElementById('login-form-container');
    const registerFormContainer = document.getElementById('register-form-container');
    const registerLink = document.getElementById('register-link');
    const loginLink = document.getElementById('login-link');
    const loginBtn = document.getElementById('login-btn');
    const registerBtn = document.getElementById('register-btn');
    const passwordToggle = document.getElementById('password-toggle');
    const regPasswordToggle = document.getElementById('reg-password-toggle');
    const passwordInput = document.getElementById('password');
    const regPasswordInput = document.getElementById('reg-password');

    // 切换登录/注册表单
    registerLink.addEventListener('click', function(e) {
        e.preventDefault();
        loginFormContainer.style.display = 'none';
        registerFormContainer.style.display = 'block';
    });

    loginLink.addEventListener('click', function(e) {
        e.preventDefault();
        registerFormContainer.style.display = 'none';
        loginFormContainer.style.display = 'block';
    });

    // 密码可见性切换
    function togglePasswordVisibility(input, toggle) {
        const type = input.getAttribute('type') === 'password' ? 'text' : 'password';
        input.setAttribute('type', type);
        toggle.querySelector('i').classList.toggle('fa-eye');
        toggle.querySelector('i').classList.toggle('fa-eye-slash');
    }

    passwordToggle.addEventListener('click', function() {
        togglePasswordVisibility(passwordInput, passwordToggle);
    });

    regPasswordToggle.addEventListener('click', function() {
        togglePasswordVisibility(regPasswordInput, regPasswordToggle);
    });

    // 登录功能
    loginBtn.addEventListener('click', function() {
        const username = document.getElementById('username').value;
        const password = document.getElementById('password').value;

        // 简单验证
        if (!username) {
            showError('username-error', '请输入用户名');
            return;
        }

        if (!password) {
            showError('password-error', '请输入密码');
            return;
        }

        // 模拟登录成功
        document.getElementById('username-error').style.display = 'none';
        document.getElementById('password-error').style.display = 'none';

        // 显示加载效果
        loginBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 登录中...';
        loginBtn.disabled = true;

        // 模拟API请求
        setTimeout(() => {
            // 实际项目中这里会发送AJAX请求
            alert('登录成功！即将跳转至系统首页');

            // 恢复按钮状态
            loginBtn.innerHTML = '登 录';
            loginBtn.disabled = false;

            // 实际项目中会重定向
            window.location.href = '/index';
        }, 1500);
    });

    // 注册功能
    registerBtn.addEventListener('click', function() {
        const username = document.getElementById('reg-username').value;
        const password = document.getElementById('reg-password').value;
        const confirmPassword = document.getElementById('confirm-password').value;

        // 重置错误信息
        resetErrors();

        // 验证
        let valid = true;

        if (!username) {
            showError('reg-username-error', '请输入用户名');
            valid = false;
        }

        if (!password) {
            showError('reg-password-error', '请输入密码');
            valid = false;
        } else if (password.length < 8) {
            showError('reg-password-error', '密码长度至少8位');
            valid = false;
        }

        if (!confirmPassword) {
            showError('confirm-password-error', '请确认密码');
            valid = false;
        } else if (password !== confirmPassword) {
            showError('confirm-password-error', '两次输入的密码不一致');
            valid = false;
        }

        if (!valid) return;

        // 显示加载效果
        registerBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> 注册中...';
        registerBtn.disabled = true;

        // 模拟API请求
        setTimeout(() => {
            // 实际项目中这里会发送AJAX请求
            alert('注册成功！请登录');

            // 恢复按钮状态
            registerBtn.innerHTML = '注 册';
            registerBtn.disabled = false;

            // 切换到登录表单
            registerFormContainer.style.display = 'none';
            loginFormContainer.style.display = 'block';

            // 自动填充用户名
            document.getElementById('username').value = username;
        }, 1500);
    });

    // 辅助函数
    function showError(elementId, message) {
        const errorElement = document.getElementById(elementId);
        errorElement.textContent = message;
        errorElement.style.display = 'block';
    }

    function resetErrors() {
        const errors = document.querySelectorAll('.error-message');
        errors.forEach(error => {
            error.textContent = '';
            error.style.display = 'none';
        });
    }
</script>
</body>
</html>